<!DOCTYPE html>
<html lang="en">
  <head>
    <title>MongoCollection Class Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset='utf-8'>
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
  </head>
  <body>
    <a name="//apple_ref/swift/Class/MongoCollection" class="dashAnchor"></a>
    <a title="MongoCollection Class Reference"></a>
    <header>
      <div class="content-wrapper">
        <p><a href="../index.html"> Docs</a> (100% documented)</p>
      </div>
    </header>
    <div class="content-wrapper">
      <p id="breadcrumbs">
        <a href="../index.html"> Reference</a>
        <img id="carat" src="../img/carat.png" />
        MongoCollection Class Reference
      </p>
    </div>
    <div class="content-wrapper">
      <nav class="sidebar">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a href="../Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Classes/BSON.html">BSON</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/MongoClient.html">MongoClient</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/MongoClientPool.html">MongoClientPool</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/MongoCollection.html">MongoCollection</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/MongoCursor.html">MongoCursor</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/MongoDatabase.html">MongoDatabase</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/MongoIndexOptions.html">MongoIndexOptions</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/MongoIndexOptionsGeo.html">MongoIndexOptionsGeo</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Enums.html">Enums</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Enums/BSONError.html">BSONError</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/MongoClientError.html">MongoClientError</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/MongoIndexStorageOptionType.html">MongoIndexStorageOptionType</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/MongoInsertFlag.html">MongoInsertFlag</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/MongoRemoveFlag.html">MongoRemoveFlag</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/MongoResult.html">MongoResult</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/MongoUpdateFlag.html">MongoUpdateFlag</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Functions.html">Functions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Functions.html#/s:ZF7MongoDBoi1lFTCS_4BSONS0__Sb">&lt;(_:_:)</a>
              </li>
              <li class="nav-group-task">
                <a href="../Functions.html#/s:ZF7MongoDBoi2eeFTCS_4BSONS0__Sb">==(_:_:)</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Structs.html">Structs</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Structs/MongoQueryFlag.html">MongoQueryFlag</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">
        <section>
          <section class="section">
            <h1>MongoCollection</h1>
              <div class="declaration">
                <div class="language">
                  <pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">MongoCollection</span></code></pre>

                </div>
              </div>
            <p>The MongoCollection class</p>

          </section>
          <section class="section task-group-section">
            <div class="task-group">
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:C7MongoDB15MongoCollection6Result"></a>
                    <a name="//apple_ref/swift/Alias/Result" class="dashAnchor"></a>
                    <a class="token" href="#/s:C7MongoDB15MongoCollection6Result">Result</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Result Status enum for a MongoDB event</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">Result</span> <span class="o">=</span> <span class="kt">MongoResult</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollectioncFT6clientCS_11MongoClient12databaseNameSS14collectionNameSS_S0_"></a>
                    <a name="//apple_ref/swift/Method/init(client:databaseName:collectionName:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollectioncFT6clientCS_11MongoClient12databaseNameSS14collectionNameSS_S0_">init(client:databaseName:collectionName:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>obtain access to a specified database and collection using the MongoClient</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">client</span><span class="p">:</span> <span class="kt">MongoClient</span><span class="p">,</span> <span class="nv">databaseName</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">collectionName</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>client</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>the MongoClient to be used</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>databaseName</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>String database name</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>collectionName</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>String collection name</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection5closeFT_T_"></a>
                    <a name="//apple_ref/swift/Method/close()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection5closeFT_T_">close()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>close connection to the current collection</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">close</span><span class="p">()</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection6insertFT8documentCS_4BSON4flagOS_15MongoInsertFlag_OS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/insert(document:flag:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection6insertFT8documentCS_4BSON4flagOS_15MongoInsertFlag_OS_11MongoResult">insert(document:flag:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Insert <strong>document</strong> into the current collection returning a result status</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">insert</span><span class="p">(</span><span class="n">document</span> <span class="nv">document</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">flag</span><span class="p">:</span> <span class="kt">MongoInsertFlag</span> <span class="o">=</span> <span class="o">.</span><span class="kt">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>document</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>BSON document to be inserted</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>flag</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional MongoInsertFlag defaults to .None</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>Result object with status of insert</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection6updateFTCS_4BSON8selectorS1_4flagOS_15MongoUpdateFlag_OS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/update(_:selector:flag:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection6updateFTCS_4BSON8selectorS1_4flagOS_15MongoUpdateFlag_OS_11MongoResult">update(_:selector:flag:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Update the document found using <strong>selector</strong> with the <strong>update</strong> document returning a result status</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">update</span><span class="p">(</span><span class="nv">update</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">flag</span><span class="p">:</span> <span class="kt">MongoUpdateFlag</span> <span class="o">=</span> <span class="o">.</span><span class="kt">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>update</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>BSON document to be used to update</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>selector</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>BSON document with selection criteria</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>flag</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional MongoUpdateFlag defaults to .None</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>Result object with status of update</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection6removeFT8selectorCS_4BSON4flagOS_15MongoRemoveFlag_OS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/remove(selector:flag:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection6removeFT8selectorCS_4BSON4flagOS_15MongoRemoveFlag_OS_11MongoResult">remove(selector:flag:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove the document found using <strong>selector</strong> returning a result status</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">remove</span><span class="p">(</span><span class="n">selector</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">flag</span><span class="p">:</span> <span class="kt">MongoRemoveFlag</span> <span class="o">=</span> <span class="o">.</span><span class="kt">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>selector</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>BSON document with selection criteria</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>flag</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional MongoRemoveFlag defaults to .None</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>Result object with status of removal</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection4saveFT8documentCS_4BSON_OS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/save(document:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection4saveFT8documentCS_4BSON_OS_11MongoResult">save(document:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Updates <strong>document</strong> returning a result status</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">save</span><span class="p">(</span><span class="n">document</span> <span class="nv">document</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>document</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>BSON document to be saved</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>Result object with status of save</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection6renameFTSS17newCollectionNameSS12dropExistingSb_OS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/rename(_:newCollectionName:dropExisting:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection6renameFTSS17newCollectionNameSS12dropExistingSb_OS_11MongoResult">rename(_:newCollectionName:dropExisting:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Renames the collection using <strong>newDbName</strong> and <strong>newCollectionName</strong>, with option to drop existing collection immediately instead of after the move, returning a result status</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">rename</span><span class="p">(</span><span class="nv">newDbName</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">newCollectionName</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">dropExisting</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>newDbName</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>String name for db after move</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>newCollectionName</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>String name for collection after move</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>dropExisting</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Bool option to drop existing collection immediately instead of after move</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>Result object with status of renaming</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection4nameFT_SS"></a>
                    <a name="//apple_ref/swift/Method/name()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection4nameFT_SS">name()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The collection name as a String</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">name</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">String</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>String the name of the current collection</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection8validateFCS_4BSONOS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/validate(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection8validateFCS_4BSONOS_11MongoResult">validate(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Validates a collection. The method scans a collection’s data structures for correctness and returns a single document that describes the relationship between the logical collection and the physical representation of the data.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">validate</span><span class="p">(</span><span class="nv">options</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>options</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. Specify true to enable a full validation and to return full statistics. MongoDB disables full validation by default because it is a potentially resource-intensive operation.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>BSON document describing the relationship between the collection and its physical representation</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection5statsFCS_4BSONOS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/stats(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection5statsFCS_4BSONOS_11MongoResult">stats(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns statistics about the collection formatted according to the options document.</p>

<ul>
<li><p><strong>The options document can contain the following fields and values</strong>:</p></li>
<li><p><strong>scale</strong>:  <em>number</em>, Optional. The scale used in the output to display the sizes of items. By default, output displays sizes in bytes. To display kilobytes rather than bytes, specify a scale value of 1024.</p></li>
<li><p><strong>indexDetails</strong>:   <em>boolean</em>, Optional. If true, <strong>stats()</strong> returns index details in addition to the collection stats. Only works for WiredTiger storage engine. Defaults to false.</p></li>
<li><p><strong>indexDetailsKey</strong>:    <em>document</em>, Optional. If <strong>indexDetails</strong> is true, you can use <strong>indexDetailsKey</strong> to filter index details by specifying the index key specification. Only the index that exactly matches <strong>indexDetailsKey</strong> will be returned. If no match is found, <strong>indexDetails</strong> will display statistics for all indexes.</p></li>
<li><p><strong>indexDetailsName</strong>:   <em>string</em>, Optional. If <strong>indexDetails</strong> is true, you can use <strong>indexDetailsName</strong> to filter index details by specifying the index name. Only the index name that exactly matches <strong>indexDetailsName</strong> will be returned. If no match is found, <strong>indexDetails</strong> will display statistics for all indexes.</p></li>
</ul>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">stats</span><span class="p">(</span><span class="nv">options</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>options</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>a BSON document defining the format of return.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>BSON document with formatted statistics or Results error document</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection4findFTCS_4BSON6fieldsGSqS1__5flagsVS_14MongoQueryFlag4skipSi5limitSi9batchSizeSi_GSqCS_11MongoCursor_"></a>
                    <a name="//apple_ref/swift/Method/find(_:fields:flags:skip:limit:batchSize:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection4findFTCS_4BSON6fieldsGSqS1__5flagsVS_14MongoQueryFlag4skipSi5limitSi9batchSizeSi_GSqCS_11MongoCursor_">find(_:fields:flags:skip:limit:batchSize:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Selects documents in a collection and returns a cursor to the selected documents.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">find</span><span class="p">(</span><span class="nv">query</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">fields</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">,</span> <span class="nv">flags</span><span class="p">:</span> <span class="kt">MongoQueryFlag</span> <span class="o">=</span> <span class="kt">MongoQueryFlag</span><span class="o">.</span><span class="kt">None</span><span class="p">,</span> <span class="nv">skip</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">limit</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">batchSize</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">MongoCursor</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>query</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. Specifies selection filter using query operators. To return all documents in a collection, omit this- Parameter or pass an empty document ({}).</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>fields</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. Specifies the fields to return in the documents that match the query filter. To return all fields in the matching documents, omit this parameter.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>flags</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. set queryFlags for the current search</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>skip</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. Skip the supplied number of records.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>limit</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. return no more than the supplied number of records.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>batchSize</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. Change number of automatically iterated documents.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>A cursor to the documents that match the query criteria. When the find() method “returns documents,” the method is actually returning a cursor to the documents.</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection11createIndexFTCS_4BSON7optionsCS_17MongoIndexOptions_OS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/createIndex(_:options:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection11createIndexFTCS_4BSON7optionsCS_17MongoIndexOptions_OS_11MongoResult">createIndex(_:options:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Creates indexes on collections.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">createIndex</span><span class="p">(</span><span class="nv">keys</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">options</span><span class="p">:</span> <span class="kt">MongoIndexOptions</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>keys</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A document that conains the field and value pairs where the field is the index key and the value describes the type of index for that field. For an ascending index on a field, specify a value of 1; for descending index, specify a value of -1.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>options</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. A document that contains a set of options that controls the creation of the index. see MongoIndexOptions for details.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>a Result status</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection9dropIndexFSSOS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/dropIndex(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection9dropIndexFSSOS_11MongoResult">dropIndex(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Drops or removes the specified index from a collection.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">dropIndex</span><span class="p">(</span><span class="nv">name</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>index</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Specifies the index to drop, either by name or by the index specification document.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>a Result status</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection4dropFT_OS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/drop()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection4dropFT_OS_11MongoResult">drop()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Removes a collection from the database. The method also removes any indexes associated with the dropped collection.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">drop</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>a Result status</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection5countFTCS_4BSON6fieldsGSqS1__5flagsVS_14MongoQueryFlag4skipSi5limitSi9batchSizeSi_OS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/count(_:fields:flags:skip:limit:batchSize:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection5countFTCS_4BSON6fieldsGSqS1__5flagsVS_14MongoQueryFlag4skipSi5limitSi9batchSizeSi_OS_11MongoResult">count(_:fields:flags:skip:limit:batchSize:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The count of documents that would match a find() query.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">count</span><span class="p">(</span><span class="nv">query</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">fields</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">,</span> <span class="nv">flags</span><span class="p">:</span> <span class="kt">MongoQueryFlag</span> <span class="o">=</span> <span class="kt">MongoQueryFlag</span><span class="o">.</span><span class="kt">None</span><span class="p">,</span> <span class="nv">skip</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">limit</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">batchSize</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>query</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The query selection criteria.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>fields</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. Specifies the fields to return in the documents that match the query filter. To return all fields in the matching documents, omit this parameter.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>flags</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. set queryFlags for the current search</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>skip</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. Skip the supplied number of records.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>limit</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. return no more than the supplied number of records.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>batchSize</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. Change number of automatically iterated documents.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>the count of documents that would match a find() query. The count() method does not perform the find() operation but instead counts and returns the number of results that match a query.</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection13findAndModifyFTCS_4BSON4sortS1_6updateS1_6fieldsS1_6removeSb6upsertSb3newSb_OS_11MongoResult"></a>
                    <a name="//apple_ref/swift/Method/findAndModify(_:sort:update:fields:remove:upsert:new:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection13findAndModifyFTCS_4BSON4sortS1_6updateS1_6fieldsS1_6removeSb6upsertSb3newSb_OS_11MongoResult">findAndModify(_:sort:update:fields:remove:upsert:new:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Modifies and returns a single document.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">findAndModify</span><span class="p">(</span><span class="nv">query</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">sort</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">update</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">fields</span><span class="p">:</span> <span class="kt">BSON</span><span class="p">,</span> <span class="nv">remove</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">,</span> <span class="nv">upsert</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">,</span> <span class="nv">new</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Result</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>query</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. The selection criteria for the modification. The query field employs the same query selectors as used in the db.collection.find() method. Although the query may match multiple documents, findAndModify() will only select one document to modify.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>sort</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. Determines which document the operation modifies if the query selects multiple documents. findAndModify() modifies the first document in the sort order specified by this argument.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>update</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Must specify either the remove or the update field. Performs an update of the selected document. The update field employs the same update operators or field: value specifications to modify the selected document.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>fields</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. A subset of fields to return. The fields document specifies an inclusion of a field with 1, as in: fields: { <field1>: 1, <field2>: 1, &hellip; }.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>remove</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Must specify either the remove or the update field. Removes the document specified in the query field. Set this to true to remove the selected document . The default is false.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>upsert</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. Used in conjunction with the update field. When true, findAndModify() creates a new document if no document matches the query, or if documents match the query, findAndModify() performs an update. To avoid multiple upserts, ensure that the query fields are uniquely indexed. The default is false.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>new</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Optional. When true, returns the modified document rather than the original. The findAndModify() method ignores the new option for remove operations. The default is false.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>Modifies and returns a single document. By default, the returned document does not include the modifications made on the update. To return the document with the modifications made on the update, use the new option.</p>

                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7MongoDB15MongoCollection12getLastErrorFT_CS_4BSON"></a>
                    <a name="//apple_ref/swift/Method/getLastError()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7MongoDB15MongoCollection12getLastErrorFT_CS_4BSON">getLastError()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>A BSON document with description of last transaction status</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">getLastError</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">BSON</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>BSON document with description of last transaction status</p>

                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </section>
        </section>
        <section id="footer">
          <p>&copy; 2016 <a class="link" href="" target="_blank" rel="external"></a>. All rights reserved. (Last updated: 2016-05-25)</p>
          <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.6.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
        </section>
      </article>
    </div>
  </body>
</div>
</html>
